#pragma once

#include "type.h"

namespace RenderSystem
{
	class ResManager;
	class Instance;
	class Resource
	{
	public:

		typedef std::vector< Instance* >	Instances;
		typedef Instances::iterator			InstancesIterator;
		typedef Instances::const_iterator	InstancesConstIterator;

		Resource( const String& strId, ResManager& rResMgr );
		virtual ~Resource(void);

		/**
		* Initializes the dynamic RHI resource and/or RHI render target used by this resource.
		* Called when the resource is initialized, or when reseting all RHI resources.
		* This is only called by the rendering thread.
		*/
		virtual void InitDynamicRHI() {}

		/**
		* Releases the dynamic RHI resource and/or RHI render target resources used by this resource.
		* Called when the resource is released, or when reseting all RHI resources.
		* This is only called by the rendering thread.
		*/
		virtual void ReleaseDynamicRHI() {}


		virtual bool Load( const String& strPath ) = 0;
		virtual bool Unload( void ) = 0;

		const String& GetResourceId( void ) const;

		virtual Instance* CreateInstance( const String& strInstanceId );

		uint32 GetInstanceNum( void ) const;

	protected:

		virtual Instance* _CreateInstanceImpl( const String& strInstanceId ) = 0;

	protected:

		String			m_strId;
		String			m_strResourcePath;
		Instances		m_Instances;

		ResManager&		m_rResMgr;
	};
}